<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateQiiUserMemberTable extends Migration
{
    /**
     * Schema table name to migrate
     * @var string
     */
    public $set_schema_table = 'qii_user_member';

    /**
     * Run the migrations.
     * @table qii_user_member
     *
     * @return void
     */
    public function up()
    {
        if (Schema::hasTable($this->set_schema_table)) return;
        Schema::create($this->set_schema_table, function (Blueprint $table) {
            $table->engine = 'InnoDB';
            $table->increments('uid')->comment('会员ID');
            $table->string('login', 40);
            $table->string('username', 40)->default('')->comment('用户名');
            $table->string('pwd', 20);
            $table->string('nickname', 16)->default('')->comment('昵称');
            $table->unsignedInteger('login_time')->default('0')->comment('登录次数');
            $table->bigInteger('reg_ip')->default('0')->comment('注册IP');
            $table->unsignedInteger('reg_time')->default('0')->comment('注册时间');
            $table->bigInteger('last_login_ip')->default('0')->comment('最后登录IP');
            $table->unsignedInteger('last_login_time')->default('0')->comment('最后登录时间');
            $table->tinyInteger('status')->default('0')->comment('状态');

            $table->index(["status"], 'status');

            $table->index(["pwd"], 'pwd');

            $table->unique(["login"], 'login');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
     public function down()
     {
       Schema::dropIfExists($this->set_schema_table);
     }
}
